package com.daotingli.backendprograms.Service.Author.individual;

import com.daotingli.backendprograms.Repository.Author.individual.IndividualRepository;
import com.daotingli.backendprograms.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class IndividualService {

    @Autowired
    private IndividualRepository individualRepository;

    public Result getAll(String username, String password) {
        return  Result.success( individualRepository.getAll(username, password));
    }

    public Result edit(int id, String username, String password, String identity, String userphone) {
        Map<String, Object> map = individualRepository.edit(id, username, password, identity, userphone);
        if("success".equals(map.get("status"))){
            return Result.success();
        }else{
            return Result.error((String) map.get("message"));
        }
    }

    public Result getAuthorBookIDs(int id) {
        return Result.success(individualRepository.getAuthorBookIDs(id));
    }
}
